function ajax(url,data=null,type='get'){
  return new Promise((resolve,reject)=>{
    let xhr = new XMLHttpRequest();
    // 判断请求方式
    if(type == 'post'){
      xhr.open(type,url)
      xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
      xhr.send(data);
    }else{
      xhr.open(type,`${url}?${data}`);
      xhr.send();
    }
    xhr.onreadystatechange = function(){
      if(xhr.status == 200){
        if(xhr.readyState == 4){
          resolve(JSON.parse(xhr.responseText));
        }
      }else{
        reject('请求失败');
      }
    }
  })
}
function mkli(res){
  return res.map(v=>{
    return `<tr>
      <td>${v.id}</td>
      <td>${v.name}</td>
      <td>${v.gender}</td>
      <td>${v.age}</td>
      <td onclick=del(${v.id})>删除</td>
    </tr>`
  }).join('')
}